package gov.child.entities.po;

import gov.child.entities.vo.annotation.Alias;
import gov.child.entities.vo.annotation.IgnoreField;

import javax.persistence.*;
import java.util.Date;

/**
 * @author fzh
 * @since 2017/9/16
 */
@Entity
@Table(name = "consult", schema = "gov_c")
public class EConsult {
    @Alias("consultId")
    private Integer id;
    private Integer deptId;
    private Integer userId;
    private String tel;
    private String addr;
    private String addrCode;
    private String item;
    private String title;
    private String content;
    @IgnoreField
    private EDepartment deptByDeptId;
    @IgnoreField
    private EUser userByUserId;
    @IgnoreField
    private EUser userByUserId_0;
    private Date createTime;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "dept_id", nullable = false)
    public Integer getDeptId() {
        return deptId;
    }

    public void setDeptId(Integer deptId) {
        this.deptId = deptId;
    }

    @Basic
    @Column(name = "user_id", nullable = true)
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "tel", nullable = false, length = 14)
    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    @Basic
    @Column(name = "addr", nullable = true, length = 40)
    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    @Basic
    @Column(name = "addr_code", nullable = true, length = 6)
    public String getAddrCode() {
        return addrCode;
    }

    public void setAddrCode(String addrCode) {
        this.addrCode = addrCode;
    }

    @Basic
    @Column(name = "item", nullable = true, length = 20)
    public String getItem() {
        return item;
    }

    public void setItem(String item) {
        this.item = item;
    }

    @Basic
    @Column(name = "title", nullable = false, length = 30)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic
    @Column(name = "content", nullable = true, length = 400)
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        EConsult consult = (EConsult) o;

        if (id != null ? !id.equals(consult.id) : consult.id != null) return false;
        if (deptId != null ? !deptId.equals(consult.deptId) : consult.deptId != null) return false;
        if (userId != null ? !userId.equals(consult.userId) : consult.userId != null) return false;
        if (tel != null ? !tel.equals(consult.tel) : consult.tel != null) return false;
        if (addr != null ? !addr.equals(consult.addr) : consult.addr != null) return false;
        if (addrCode != null ? !addrCode.equals(consult.addrCode) : consult.addrCode != null) return false;
        if (item != null ? !item.equals(consult.item) : consult.item != null) return false;
        if (title != null ? !title.equals(consult.title) : consult.title != null) return false;
        if (content != null ? !content.equals(consult.content) : consult.content != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (deptId != null ? deptId.hashCode() : 0);
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (tel != null ? tel.hashCode() : 0);
        result = 31 * result + (addr != null ? addr.hashCode() : 0);
        result = 31 * result + (addrCode != null ? addrCode.hashCode() : 0);
        result = 31 * result + (item != null ? item.hashCode() : 0);
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + (content != null ? content.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "dept_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
    public EDepartment getDeptByDeptId() {
        return deptByDeptId;
    }

    public void setDeptByDeptId(EDepartment deptByDeptId) {
        this.deptByDeptId = deptByDeptId;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "id", insertable = false, updatable = false)
    public EUser getUserByUserId() {
        return userByUserId;
    }

    public void setUserByUserId(EUser userByUserId) {
        this.userByUserId = userByUserId;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "id", insertable = false, updatable = false)
    public EUser getUserByUserId_0() {
        return userByUserId_0;
    }

    public void setUserByUserId_0(EUser userByUserId_0) {
        this.userByUserId_0 = userByUserId_0;
    }
}
